21 #define D(x) cout << #x " is " << x << endl
27 while (scanf("%d", &len
)==1){
28 memset(g
, 0x3F, sizeof g
);
30 for (int i
=1; i
<20; ++i
){
31 if (i
> 1) scanf("%d", &len
);
32 for (int t
=len
, x
; t
--; ){
34 g
[i
][x
] = g
[x
][i
] = 1;
38 for (int k
=1; k
<=20; ++k
)
39 for (int i
=1; i
<=20; ++i
)
40 for (int j
=1; j
<=20; ++j
)
41 g
[i
][j
] = min(g
[i
][j
], g
[i
][k
] + g
[k
][j
]);
43 printf("Test Set #%d\n", C
++);
45 for (scanf("%d", &q
); q
--; ){
47 scanf("%d %d", &u
, &v
);
48 printf("%2d to %2d: %d\n", u
, v
, g
[u
][v
]);